import React from 'react';

// 函数式组件使用state
import {useState} from "react";
import {Navigate} from "react-router-dom";

function About(props) {

    const [sum,setSum]=useState(0)

    function add(){
        setSum(2)
    }
    return (
        <div className="col-xs-6">
            <div className="panel">
                <div className="panel-body">
                    {sum===2?<Navigate to='/home'></Navigate>:<h3>我是About的内容</h3>}

                    <h1>sum的值是{sum}</h1>
                    <button onClick={add}>点我sum变成2</button>
                </div>
            </div>
        </div>
    );
}

export default About;